import React from "react";
import { View, Text, StyleSheet, TouchableOpacity } from "react-native";
import { AntDesign } from "@expo/vector-icons";
import ArticleDetailCard from "../../components/preAdmin/ArticleDetailCard";

const ArticleDetail = ({ route, navigation }) => {
  const { article } = route.params;

  React.useLayoutEffect(() => {
    console.log("进来");

    navigation.setOptions({
      headerRight: () => (
        <TouchableOpacity
          onPress={() => {
            navigation.navigate("EditArticle", {
              article: article,
              title: "编辑商品",
            });
          }}
        >
          <AntDesign name="edit" size={22} color="#fff" />
        </TouchableOpacity>
      ),
    });
  }, [navigation, article]);

  return (
    <View style={styles.container}>
      <View style={{ marginBottom: 10 }}>
        <ArticleDetailCard article={article} />
      </View>
    </View>
  );
};

var styles = StyleSheet.create({
  container: {
    height: "100%",
    backgroundColor: "white",
  },
});

export default ArticleDetail;
